/**
 * 
 */
package com.ms.game.invitefriend.async;

import java.util.ArrayList;

import com.ms.game.invitefriend.db.InviteFriendDAO;
import com.ms.game.invitefriend.message.ComSumInfo;
import com.ms.game.invitefriend.message.SGetCommissionDetailResponse;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.message.MessageAction;
import com.xpec.c4.service.module.task.TaskAsyncCommand;

/**
 * 取得角色的各等級區間抽佣金額加總清單
 * 
 * @author TW15010
 */
public class GetCommissionDetailAsync extends TaskAsyncCommand {
	/**
	 * 查詢角色的 guid
	 */
	public GUID queryPlayerGuid;

	/**
	 * 要傳回資料的 client session id
	 */
	public GUID returnSessionId;

	/**
	 * @param queryPlayerGuid
	 * @param returnSessionId
	 */
	public GetCommissionDetailAsync(GUID queryPlayerGuid, GUID returnSessionId) {
		super();
		this.queryPlayerGuid = queryPlayerGuid;
		this.returnSessionId = returnSessionId;
	}

	/**
	 * 回傳值，等級區間用金額加總清單
	 */
	public ArrayList<ComSumInfo> comSumList;

	@Override
	public void asyncExecute() throws Exception {
		// 取得清單
		comSumList = InviteFriendDAO.loadCommissionSumList(queryPlayerGuid);
	}

	@Override
	public void execute() throws Exception {
		SGetCommissionDetailResponse response = new SGetCommissionDetailResponse();
		response.setComSumList(comSumList);

		// 回傳給 client
		MessageAction.sendMessage(returnSessionId, MessageTypes.S_CHARACTER_INFO_GET_COMMISSION_DETAIL_RESPONSE,
				response);
	}
}
